// pages/mine/mine.js
import { getShopSearch, getDetail } from '../request/api'
Page({
    /**
     * 页面的初始数据
     */
    data: {
        active: 0,
        QueryParams:{
            pagenum:1, //第几页
            pagesize:10 //1页几条
        },
        goodsList: [],//列表
        totalPages:5,
    },
    go(e) {
        console.log(e.target.dataset.id);
        let id=e.target.dataset.id     
        wx.navigateTo({
            url: '../detail/detail?id='+id
        })
    },
    onChange(event) {
        wx.showToast({
            title: `切换到标签 ${event.detail.name}`,
            icon: 'none',
        });
    },
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad(options) {
        console.log(options);
        this.data.QueryParams.query=options.query||'服饰';
        // 走接口
        console.log(this.data.QueryParams);
        getShopSearch(this.data.QueryParams).then(res => {     
            console.log(res);
            this.setData({
               goodsList:[...res.message.goods]
           })
        })    
    },
    // 下拉
 onPullDownRefresh() {
console.log(1);
this.data.QueryParams.pagenum=1
     this.getShopSearch()
    },
    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom() {
        console.log(123);
        this.data.QueryParams.pagenum++
        console.log(113,this.data.QueryParams);
      
        getShopSearch(this.data.QueryParams).then(res => {     
        //    console.log(res);
            this.data.goodsList = this.data.goodsList.concat(res.message.goods)
            console.log(this.data.goodsList);
            this.setData({
                goodsList: this.data.goodsList
            })
        })
    },

  
})